package com.ticket.web.controller.yanchu;

import com.ticket.common.annotation.Log;
import com.ticket.common.core.domain.AjaxResult;
import com.ticket.common.enums.BusinessType;
import com.ticket.system.domain.vo.OrderStatisticsVO;
import com.ticket.system.domain.vo.QueryOrderListVO;
import com.ticket.system.service.IYanchuOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * @ClassName : YanchuOrderStatistics
 * @Description :
 * @Author : lixiang
 * @Date: 2023/12/27  14:37
 */
@Api(description = "订单统计相关")
@RequestMapping("/system/orderStatistics")
@RestController
public class YanchuOrderStatisticsController {

    @Autowired
    private IYanchuOrderService iYanchuOrderService;
    @ApiOperation("管理端查询订单统计")
    @ApiImplicitParam(name = "query", value = "订单对象", dataType = "QueryOrderListVO", dataTypeClass = QueryOrderListVO.class)
    @PreAuthorize("@ss.hasPermi('system:order:list')")
    @GetMapping("/statistics")
    public AjaxResult<OrderStatisticsVO> list(QueryOrderListVO query)
    {
        OrderStatisticsVO orderStatisticsVO = iYanchuOrderService.getOrderStatisticsVO(query);
        return AjaxResult.success(orderStatisticsVO);
    }

    @ApiOperation("管理端导出订单统计")
    @PreAuthorize("@ss.hasPermi('system:detail:export')")
    @Log(title = "订单详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QueryOrderListVO query) {
        iYanchuOrderService.exportOrderStatistics(response, query);
    }
}
